// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database();
// 云函数入口函数
// 添加一个数据到like表
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()

  const cp = event.cp;
  const classifyId = event.classifyId;
  let like = {
    openid:wxContext.OPENID,
    classifyId,
    cp
  };

  let result = await db.collection("like").add({
    data:like
  });

  return {
    code:200,
    msg:"添加喜欢成功"
  }


  return {
    // event,
    // result
    // openid: wxContext.OPENID,
    // appid: wxContext.APPID,
    // unionid: wxContext.UNIONID,
  }
}